Trò chơi Tic-Tac-Toe, game đánh caro full source code
53.585 lượt xem;
- PhotonTransformViewRotationControl.cs
- Views /
- PhotonNetwork /
- Plugins /
- Photon Unity Networking /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 public class PhotonTransformViewRotationControl
5 {
6 PhotonTransformViewRotationModel m_Model;
7 Quaternion m_NetworkRotation;
8
9 public PhotonTransformViewRotationControl( PhotonTransformViewRotationModel model )
10 {
11 m_Model = model;
12 }
13
14 public Quaternion GetRotation( Quaternion currentRotation )
15 {
16 switch( m_Model.InterpolateOption )
17 {
18 default:
19 case PhotonTransformViewRotationModel.InterpolateOptions.Disabled:
20 return m_NetworkRotation;
21 case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
22 return Quaternion.RotateTowards( currentRotation, m_NetworkRotation, m_Model.InterpolateRotateTowardsSpeed * Time.deltaTime );
23 case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
24 return Quaternion.Lerp( currentRotation, m_NetworkRotation, m_Model.InterpolateLerpSpeed * Time.deltaTime );
25 }
26 }
27
28 public void OnPhotonSerializeView( Quaternion currentRotation, PhotonStream stream, PhotonMessageInfo info )
29 {
30 if( m_Model.SynchronizeEnabled == false )
31 {
32 return;
33 }
34
35 if( stream.isWriting == true )
36 {
37 stream.SendNext( currentRotation );
38 }
39 else
40 {
41 m_NetworkRotation = (Quaternion)stream.ReceiveNext();
42 }
43 }
44 }
2 using System.Collections;
3
4 public class PhotonTransformViewRotationControl
5 {
6 PhotonTransformViewRotationModel m_Model;
7 Quaternion m_NetworkRotation;
8
9 public PhotonTransformViewRotationControl( PhotonTransformViewRotationModel model )
10 {
11 m_Model = model;
12 }
13
14 public Quaternion GetRotation( Quaternion currentRotation )
15 {
16 switch( m_Model.InterpolateOption )
17 {
18 default:
19 case PhotonTransformViewRotationModel.InterpolateOptions.Disabled:
20 return m_NetworkRotation;
21 case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
22 return Quaternion.RotateTowards( currentRotation, m_NetworkRotation, m_Model.InterpolateRotateTowardsSpeed * Time.deltaTime );
23 case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
24 return Quaternion.Lerp( currentRotation, m_NetworkRotation, m_Model.InterpolateLerpSpeed * Time.deltaTime );
25 }
26 }
27
28 public void OnPhotonSerializeView( Quaternion currentRotation, PhotonStream stream, PhotonMessageInfo info )
29 {
30 if( m_Model.SynchronizeEnabled == false )
31 {
32 return;
33 }
34
35 if( stream.isWriting == true )
36 {
37 stream.SendNext( currentRotation );
38 }
39 else
40 {
41 m_NetworkRotation = (Quaternion)stream.ReceiveNext();
42 }
43 }
44 }